/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication6.UI;

/**
 *
 * @author meydlo
 */
import java.util.Scanner;
public class Listener {

    //
    public String getLineString()
    {
        String line="";
        do{
            Scanner scanner=new Scanner(System.in);
            line=scanner.nextLine().trim();
        }while(line.equals(""));
            return line;
    }

    //
    public int getLineInt()
    {
        int number=0;
        do{
            try{
                String line=getLineString();
                number=Integer.parseInt(line);
            }
            catch(Exception e)
            {
                System.out.println("Please write a number");
            }
            if(number<=0) System.out.println("write a positive number");
        }while(number<=0);
        return number;
    }


     public double getLineDouble()
    {
         double number=-20;
         do{
            try{
                String line=getLineString();
                number=Double.parseDouble(line);
            }
            catch(Exception e)
            {
                System.out.println("Please write number of double");
            }
         }while(number<0);
         return number;
    }


      public boolean getLineBoolean()
    {
          boolean answer=true;
          boolean exit=false;
        do{
            String line=getLineString();
            if(line.equals("yes")||line.equals("y")){
                answer=true;
                exit=true;
            }
            if(line.equals("no")||line.equals("n")){
                answer=false;
                exit=true;
            }
        }while(exit==false);
          return answer;
    }



}
